from rest_framework import serializers

from goods.models import SKU
from orders.models import OrderInfo, OrderGoods

class skuSerializer(serializers.ModelSerializer):

    class Meta:
        model = SKU
        fields = ("name","default_image")


class OrderGoodsSerializer(serializers.ModelSerializer):
    sku = skuSerializer(read_only=True)
    class Meta:
        model = OrderGoods
        fields = ("count","price","sku")

class OrderSerializer(serializers.ModelSerializer):
    skus = OrderGoodsSerializer(read_only=True,many=True)
    class Meta:
        model = OrderInfo
        fields = "__all__"